import { h } from 'vue';
import { BasicColumn } from '@/components/Table';

export const columns: BasicColumn[] = [
  {
    title: 'id',
    dataIndex: 'id',
    width: 100,
  },
  {
    title: '编码',
    dataIndex: 'no',
    width: 100,
  },
  {
    title: '名称',
    dataIndex: 'name',
    editComponent: 'Input',
    editRow: true,
    // 默认必填校验
    editRule: true,
    edit: true,
    width: 150,
  },
  {
    title: '头像',
    dataIndex: 'avatar',
    width: 100,
    render({ record }) {
      return h('img', {
        style: 'width:40px;border-radius:50%;height:40px',
        class: 'w-10',
        src: record.avatar,
      });
    },
  },
  {
    title: '地址',
    dataIndex: 'address',
    editRow: true,
    editComponent: 'Select',
    editComponentProps: {
      options: [
        {
          label: '广东省',
          value: 1,
        },
        {
          label: '浙江省',
          value: 2,
        },
      ],
    },
    edit: true,
    width: 200,
    ellipsis: false,
  },
  {
    title: '开始日期',
    dataIndex: 'beginTime',
    editRow: true,
    edit: true,
    width: 240,
    editComponent: 'DatePicker',
    editComponentProps: {
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      format: 'YYYY-MM-DD HH:mm:ss',
    },
    ellipsis: false,
  },
  {
    title: '结束日期',
    dataIndex: 'endTime',
    width: 160,
  },
  {
    title: '状态',
    dataIndex: 'status',
    editRow: true,
    edit: true,
    width: 100,
    editComponent: 'Switch',
    editValueMap: (value) => {
      return value ? '启用' : '禁用';
    },
  },
  {
    title: '创建时间',
    dataIndex: 'date',
    width: 160,
  },
  {
    title: '停留时间',
    dataIndex: 'time',
    width: 80,
  },
];
